﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Web.API.IBLL;
using Web.API.IDAL;
using Web.API.Model;

namespace Web.API.UI.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class RoomController : ControllerBase
    {
        public RoomController(RoomIBLL bll, ILogger<RoomController> logger) 
        {
            Bll = bll;
            Logger = logger;
        }
        public RoomIBLL Bll { get;}
        public ILogger<RoomController> Logger { get;}
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="room"></param>
        /// <returns></returns>
        [HttpPost("AddRoom")]
        public Task<int> AddRoom(RoomModel room)
        {
            try
            {
                Logger.LogInformation("添加成功");
                return Bll.AddRoom(room);
            }
            catch (Exception)
            {
                throw;
            }
           
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete("DelRoom")]
        public Task<int> DelRoom(int id)
        {
            try
            {
                Logger.LogInformation("删除成功");
                return Bll.DelRoom(id);
            }
            catch (Exception)
            {
                throw;
            }
           
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetRoom")]
        public List<RoomModel> GetRoom()
        {
            try
            {
                return Bll.GetRoom();
            }
            catch (Exception)
            {
                throw;
            }
           
        }
        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("UpdStart")]
        public Task<int> UpdStart(int id)
        {
            try
            {
                Logger.LogInformation("修改成功");
                return Bll.UpdStart(id);
            }
            catch (Exception)
            {
                throw;
            }
           
        }
    }
}
